<?	/*
	// File:	webware.wcp.phps
	// Purpose:	Webware Support
	// Author:	Felix <webmaster@can-host.com>
	*/



// Handle domains manipulation
if ($type == "domain") {
	if ($data['type'] == 'domain')
		$gid = "g".$data['id'];
	else
		$gid = "g".$data['owner'];
	// Handle Domain Creation :: expect *
	if ($data['action'] == 'create') {
		if ($data['serverside']['webware'] == "on") {
			if ($data['type'] == 'domain' OR $data['type'] == 'subdomain')
				$path = $data['path']."/".$data['host'].$cfg['webname'];
			else
				$path = $data['path'];
			
			if (is_dir($path)) {
				$wwdir = $path."/".$cfg['ss']['webware_dir'];
				mkdir($wwdir,0775);
				chmod($wwdir,0775);
				chgrp($wwdir,$gid);
				exec($cfg['webware_init']." ".$wwdir);
			}
		}
	}
	
	// Handle Domain updates :: expect *
	elseif ($data['action'] == 'update') {
		if ($data['serverside']['webware'] == "on") {
			if ($data['type'] == 'domain' OR $data['type'] == 'subdomain')
				$path = $data['path']."/".$data['host'].$cfg['webname'];
			else
				$path = $data['path'];
			
			if (is_dir($path)) {
				$wwdir = $path."/".$cfg['ss']['webware_dir'];
				if (!is_dir($wwdir)) {
					mkdir($wwdir,0775);
					chmod($wwdir,0775);
					chgrp($wwdir,$gid);
					exec($cfg['webware_init']." ".$wwdir);
				}
			}
		}
	}
}
					
					